{extend name='admin@public/content'}

{block name="button"}
<button data-open='{:url("$classuri/")}' data-title="返回列表" class='layui-btn layui-btn-sm layui-btn-primary'><i class='fa fa-arrow-left'></i> 返回列表</button>
{/block}

{block name='content'}

<!--右侧编辑区 开始-->
<div class="panel panel-default article-right" style="overflow:hidden;width: 96rem;">
    <div class="panel-body">
        <form class="form-horizontal" action="{:url()}" data-auto="true" method="post">
            <input type="hidden" name="id" value='{$vo.id|default=""}'>

            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">机构名称</span>
                        <input class="layui-input rw60" maxlength="200" required="required"  name="name" value="{$vo.name|default=''}" title="机构名称不能为空哦" placeholder="输入机构名称">
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">机构类别</span>
                        <select name='category_id' class='input-sm form-control' style="width:20rem;">
                            {foreach $category as $key=>$cate}
                            <option  value='{$key}' {if isset($vo.category_id) and ($key == $vo.category_id)}selected{/if}>{$cate}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">服务地区</span>
                        <select required name='province_id' id="province_id" class='layui-select rw10'>
                        </select>
                        <select required name='city_id' id="city_id" class='layui-select rw10'>
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">详细地址</span>
                        <input class="layui-input rw60" name='address' value="{$vo.address|default=''}">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">工作时间</span>
                        <input class="layui-input rw20" name='worktime' title="工作时间不能为空哦" placeholder="设置工作时间" value="{$vo.worktime|default=''}">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">费用说明</span>
                        <select name='price' class='input-sm form-control' style="width:20rem;">
                            {foreach $price_type as $key=>$cate}
                            <option  value='{$key}' {if isset($vo.price) and ($key == $vo.price)}selected{/if}>{$cate}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">联系电话</span>
                        <input class="layui-input rw20" name='phone' title="联系电话不能为空哦" placeholder="设置联系电话" value="{$vo.phone|default=''}">
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">微信</span>
                        <input class="layui-input rw20" name='weixin' title="微信不能为空哦" placeholder="设置微信" value="{$vo.weixin|default=''}">
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">网站</span>
                        <input class="layui-input rw60" name='web_site' placeholder="输入网站网址" value="{$vo.web_site|default=''}">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group">
                        <span class="input-group-addon rw12">logo</span>

                        <div class="form-control" style="height:auto">
                            <div class="row nowrap">
                                <div class="col-xs-3" style="width:16rem;">
                                    <div class="upload-image-box" style="background-image: url('{$vo.logo|default=$image}')">
                                        <input value="{$vo.logo|default=''}" type="hidden" name="logo">
                                    </div>
                                </div>
                                <div class="col-xs-6 rw44">
                                    <br>
                                    <a data-file="one" data-type="jpg,png,jpeg" data-field="logo" class="btn btn-sm">上传图片</a>
                                </div>
                            </div>
                            <p class="help-block" style="margin-top:10px;color:#ccc;font-size: 12px;">图片建议尺寸：1:1</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-12">
                    <div class="form-control" style="height:auto">
                        <label class="input-group-addon rw12">介绍文字</label>
                        <textarea name="intro" class="layui-input rw60" style="height: 200px">{$vo.intro|default=""}</textarea>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-12">
                    <div class="form-control" style="height:auto">
                        <label style="color:#333;font-size: 1.2rem;margin-bottom: 1rem">详细信息</label>
                        <textarea name="mainintro">{$vo.mainintro|default=""}</textarea>
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <div class="row">
                    <div class="layui-form-item text-center">
                        <button class="layui-btn" type='submit'>保存数据</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<!--右侧编辑区 结束-->

{/block}


{block name='script'}
<script>
    var areas = JSON.parse('{$area_list|raw}');
    var selectIndexP = {$vo.province_id|default="0"};
    var selectIndexC = {$vo.city_id|default="0"};
    var selectIndexS = {$vo.district_id|default="0"};
    var selectP = 0;

    $(function () {
        $('body').on('change', '.upload-image-box input', function () {
            $('.news-item.active').css('background-image', 'url(' + this.value + ')');
            $(this).parent('.upload-image-box').css('background-image', 'url(' + this.value + ')');
        });

        $('#province_id').change(function() {
            var id = $(this).children('option:selected').val();
            selectP = id;
            $("#city_id").empty();

            $.each(areas[id].city, function(idx, obj) {
                var selected = false;
                if (obj.id == selectIndexC) {
                    selected = true;
                }
                $("#city_id").append(new Option(obj.name, obj.id, false, selected));
            });

            $("#city_id").change();
        });

        // 城市选择开始
        $.each(areas, function(idx, obj) {
            var selected = false;
            if (idx == selectIndexP) {
                selected = true;
            }

            $("#province_id").append(new Option(obj.name, obj.id, false, selected));
            $("#province_id").change();
        });
    });

    // 编辑器
    require(['jquery', 'ckeditor', 'angular'], function () {
        window.form.render();
        window.createEditor('[name="mainintro"]', {height: 420});
        var app = angular.module("ProductForm", []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);

        function callback() {}
    });

    function coordinateReciever(lat, lng) {
        $("#data_lat").val(lat);
        $("#data_lng").val(lng);
    }
</script>
{/block}

{block name="style"}
<style>
    .panel{border-radius:0}
    .article-right {position:absolute;left:20px;position:absolute;}
    .article-right .layui-input{border-radius:0;border:1px solid #e5e6e7;}
    .article-right .layui-input:hover, .news-right .layui-input:focus{border-color:#e5e6e7!important;}
    .article-right .input-group-addon{background:#fff;border-radius:0;border-color:#e5e6e7;text-align:right}
    .article-right .upload-image-box{width:150px;height:120px;background-size:cover;background-position:center center;}
</style>
{/block}